import { ILoadMapTypeAll } from '@/common';
import { getSelectDataCommon, getTenantID, getLoadMapList } from '@/utils';

const loadMdicIds: string[] = [
  // `${getTenantID()}${ILoadMapTypeAll.PURCHASE_SUPPLY}`,
  // `${getTenantID()}${ILoadMapTypeAll.EXPERTS_LEVEL}`,
  `${getTenantID()}${ILoadMapTypeAll.MATERIAL_CANCEL}`,
  `${getTenantID()}${ILoadMapTypeAll.MATERIAL_TYPE}`,
  `${getTenantID()}${ILoadMapTypeAll.PURCHASE_CATEGORY}`,
  `${getTenantID()}${ILoadMapTypeAll.PURCHASE_METHOD}`,
  `${getTenantID()}${ILoadMapTypeAll.PURAPPLY_STATE}`,
  `${getTenantID()}${ILoadMapTypeAll.APPLY_CANCEL}`,
];

export const DictionaryService = () => {
  const { loadMapInfo: dictionaryData, mapLoading } = getLoadMapList(loadMdicIds);

  // 采购类型
  // const supplyList = getSelectDataCommon(dictionaryData?.[`${getTenantID()}${ILoadMapTypeAll.PURCHASE_SUPPLY}`], 'name', 'id');
  // 专家级别
  // const levelList = getSelectDataCommon(dictionaryData?.[`${getTenantID()}${ILoadMapTypeAll.EXPERTS_LEVEL}`], 'name', 'id');

  // 物料类型
  const materialTypeList = getSelectDataCommon(dictionaryData?.[`${getTenantID()}${ILoadMapTypeAll.MATERIAL_TYPE}`], 'name', 'id');

  // 采购方式
  const purchaseFs = dictionaryData?.[`${getTenantID()}${ILoadMapTypeAll.PURCHASE_METHOD}`];

  // 标的类型
  const supplyKindData = dictionaryData?.[`${getTenantID()}${ILoadMapTypeAll.PURCHASE_CATEGORY}`];

  // 采购类别  标的类型
  const supplyKindList = getSelectDataCommon(dictionaryData?.[`${getTenantID()}${ILoadMapTypeAll.PURCHASE_CATEGORY}`], 'name', 'id');

  // 申请状态
  const applyStateList = getSelectDataCommon(dictionaryData?.[`${getTenantID()}${ILoadMapTypeAll.PURAPPLY_STATE}`], 'name', 'id');

  // 申请状态
  const checkStateList = [
    {
      value: 1,
      name: '通过',
    },
    {
      value: 2,
      name: '取消',
    },
  ];

  // 采购办法
  const supplyWayList = [
    {
      value: 0,
      name: '月度计划',
    },
    {
      value: 1,
      name: '零星采购',
    },
    // {
    //   value: 2,
    //   name: '实验平台',
    // },
  ];

  // 办理审批类型
  const auditRecordTypeList = [
    {
      value: 1,
      name: '通过',
    },
    {
      value: 2,
      name: '退回',
    },
  ];

  // 取消类型
  const cancelTypeList = getSelectDataCommon(dictionaryData?.[`${getTenantID()}${ILoadMapTypeAll.APPLY_CANCEL}`], 'name', 'id');

  return {
    cancelTypeList,
    applyStateList,
    checkStateList,
    supplyWayList,
    // supplyList,
    supplyKindList,
    // levelList,
    materialTypeList,
    auditRecordTypeList,
    supplyKindData,
    purchaseFs,
    mapLoading,
  };
};
